# Contributor: Runar Tenfjord < runar dot tenfjord at gmail dot com >

_realname=dateutil
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-$_realname" "${MINGW_PACKAGE_PREFIX}-python3-$_realname")
pkgver=2.5.2
pkgrel=1
pkgdesc="Provides powerful extensions to the standard datetime module (mingw-w64)"
arch=('any')
license=('custom:PYTHON')
url="http://labix.org/python-dateutil"
makedepends=(
            "${MINGW_PACKAGE_PREFIX}-python2-setuptools"
            "${MINGW_PACKAGE_PREFIX}-python3-setuptools"
            "${MINGW_PACKAGE_PREFIX}-python2-six"
            "${MINGW_PACKAGE_PREFIX}-python3-six"
)
source=(https://pypi.python.org/packages/source/p/python-dateutil/python-dateutil-${pkgver}.tar.gz)
sha256sums=('063907ef47f6e187b8fe0728952e4effb587a34f2dc356888646f9b71fbb2e4b')

prepare() {
  cd "${srcdir}"
  cp -r python-dateutil-${pkgver} python2-build
  cp -r python-dateutil-${pkgver} python3-build
}

check() {
  cd ${srcdir}/python3-build
  ${MINGW_PREFIX}/bin/python3 test.py

  cd ${srcdir}/python2-build
  ${MINGW_PREFIX}/bin/python2 test.py
}

package_python3-dateutil() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3-six")

  cd ${srcdir}/python3-build

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} \
    --root=${pkgdir} --optimize=1

  install -Dm644 LICENSE ${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE
  chmod -R a+r $pkgdir/${MINGW_PREFIX}/lib/python3.5/

  # Remove data files
  #rm ${pkgdir}${MINGW_PREFIX}/lib/python3.5/site-packages/dateutil/zoneinfo/dateutil-zoneinfo.tar.gz
}

package_python2-dateutil() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2-six")

  cd ${srcdir}/python2-build

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
    --root=${pkgdir} --optimize=1

  install -Dm644 LICENSE ${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE
  chmod -R a+r ${pkgdir}/${MINGW_PREFIX}/lib/python2.7/

  # Remove data files
  #rm ${pkgdir}${MINGW_PREFIX}/lib/python2.7/site-packages/dateutil/zoneinfo/dateutil-zoneinfo.tar.gz
}

package_mingw-w64-i686-python2-dateutil() {
  package_python2-dateutil
}

package_mingw-w64-i686-python3-dateutil() {
  package_python3-dateutil
}

package_mingw-w64-x86_64-python2-dateutil() {
  package_python2-dateutil
}

package_mingw-w64-x86_64-python3-dateutil() {
  package_python3-dateutil
}
